package com.shirotest.component;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;

/**
 * 默认错误页配置
 */
@Configuration
public class ErrorPageConfigurer implements ErrorPageRegistrar{
	@Override
	public void registerErrorPages(ErrorPageRegistry registry) {
		ErrorPage error400Page = new ErrorPage(HttpStatus.BAD_REQUEST, "/customer/error.do");
	    ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/customer/error.do");
	    ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/customer/error.do");
	    ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/customer/error.do");
	    ErrorPage exceptionPage = new ErrorPage(Exception.class, "/customer/error.do");
	    ErrorPage throwablePage = new ErrorPage(Throwable.class, "/customer/error.do");
	    registry.addErrorPages(error400Page,error401Page,error404Page,error500Page,exceptionPage,throwablePage);
	}
}
